package com.dcivision.form.utility;
/**
 * This class is a object factory that create some form object.
 * 
 * @author Bill
 */
import com.dcivision.form.bean.FormElement;
import com.dcivision.form.bean.FormElementType;
import com.dcivision.form.bean.FormGroup;
import com.dcivision.form.bean.FormPage;
import com.dcivision.form.bean.FormRecord;
import com.dcivision.form.bean.FormSection;
import com.dcivision.form.bean.MtmFormPageFormSection;
import com.dcivision.form.bean.MtmFormSectionFormElement;
import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.Utility;

public class FormObjectFactory {
  /**
   * Get a new form group and setup some default attribute.
   * 
   * @author Bill
   */
  public static FormGroup getNewFormGroup(String groupName){
    FormGroup newFormGroup=new FormGroup();
    newFormGroup.setGroupName(groupName);
    newFormGroup.setRecordStatus("A");
    newFormGroup.setCreateDate(Utility.getCurrentTimestamp());
    return newFormGroup;
  }
  /**
   * Get a new form record and setup some default attribute.
   * 
   * @author Bill
   */
  public static FormRecord getNewFormRecord(String formCode){
    FormRecord newFormRecord=new FormRecord();
    newFormRecord.setFormCode(formCode);
    newFormRecord.setFormVersion("1");
    newFormRecord.setFormType(new Integer(FormRecord.FORM_TYPE_HTML));
    newFormRecord.setFormGroupID(new Integer(1));
    newFormRecord.setStatus(FormRecord.FORM_STATUS_PENDING);
    newFormRecord.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
    newFormRecord.setTitle("Title");
    newFormRecord.setAutoNumbering("F");
    newFormRecord.setStartDate(Utility.getCurrentTimestamp());
    return newFormRecord;
  }
  /**
   * Get a new form element and setup some default attribute.
   * 
   * @author Bill
   */
  public static FormElement getNewFormElement(String name){
	FormElement newFormElement=new FormElement();
	newFormElement.setElementType(FormElementType.ELEMENT_LABEL);
	newFormElement.setFieldName(name);
	newFormElement.setRequiredFlag(GlobalConstant.FALSE);
	newFormElement.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
	return newFormElement;
  }
  /**
   * Get a new form page and setup some default attribute.
   * 
   * @author Bill
   */
  public static FormPage getNewFormPage(String title){
	FormPage newFormPage=new FormPage();
	newFormPage.setFormRecordID(new Integer("1"));
	newFormPage.setPageNo(new Integer("0"));
	newFormPage.setTitle(title);
	newFormPage.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
	return newFormPage;
  }
  /**
   * Get a new form section and setup some default attribute.
   * 
   * @author Bill
   */
  public static FormSection getNewFormSection(String title){
	FormSection newFormSection=new FormSection();
	newFormSection.setTitle(title);
	newFormSection.setSubSection("N");
	newFormSection.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
	return newFormSection;
  }
  /**
   * Get a new mtmFormPageFormSection and setup some default attribute.
   * 
   * @author Bill
   */
  public static MtmFormPageFormSection getNewMtmFormPageFormSection(){
	MtmFormPageFormSection mtmFormPageFormSection=new MtmFormPageFormSection();
	mtmFormPageFormSection.setSectionID(new Integer(1));
	mtmFormPageFormSection.setPageID(new Integer(1));
	mtmFormPageFormSection.setSectionSeq(new Integer(1));
	mtmFormPageFormSection.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
	return mtmFormPageFormSection;
  }
  /**
   * Get a new mtmFormSectionFormElement and setup some default attribute.
   * 
   * @author Bill
   */
  public static MtmFormSectionFormElement getNewMtmFormSectionFormElement(){
	MtmFormSectionFormElement mtmFormSectionFormElement=new MtmFormSectionFormElement();
	mtmFormSectionFormElement.setSectionID(new Integer(1));
	mtmFormSectionFormElement.setElementID(new Integer(1));
	mtmFormSectionFormElement.setElementSeq(new Integer(1));
	mtmFormSectionFormElement.setRecordStatus(GlobalConstant.RECORD_STATUS_ACTIVE);
	return mtmFormSectionFormElement;
  }
}
